package problemas;

import java.util.List;

import base.Particula;
import base.Problema;

public class Sphere extends Problema {

	public Sphere()
	{
		super(30, null, null);
		
		valorMaximo = new double[numeroDimensoes];
		valorMinimo = new double[numeroDimensoes];
		for(int i=0; i<numeroDimensoes; i++){
			valorMaximo[i] = 5.12;
			valorMinimo[i] = -5.12;
		}
	}
	
	@Override
	public void avaliacaoFitness(Particula particula) {
		double fitness = 0;
		for(int i=0; i<particula.getPosicao().length; i++){
			fitness += particula.getPosicao()[i]*particula.getPosicao()[i];
		}

		particula.setFitness(fitness);
	}

	@Override
	public void avaliacaoFitness(List<Particula> particulas) {
		for(int i=0; i<particulas.size(); i++){
			avaliacaoFitness(particulas.get(i));
		}
	}

}
